/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package entities;

import java.io.Serializable;
import javax.persistence.*;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author HP
 */
@Entity
@Table(name = "like")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Like.findAll", query = "SELECT l FROM Like l"),
    @NamedQuery(name = "Like.findByUsername", query = "SELECT l FROM Like l WHERE l.likePK.username = :username"),
    @NamedQuery(name = "Like.findByLikeid", query = "SELECT l FROM Like l WHERE l.likePK.likeid = :likeid"),
    @NamedQuery(name = "Like.findByType", query = "SELECT l FROM Like l WHERE l.likePK.type = :type")})
public class Like implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected LikePK likePK;
    @JoinColumn(name = "username", referencedColumnName = "username", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private User user;

    public Like() {
    }

    public Like(LikePK likePK) {
        this.likePK = likePK;
    }

    public Like(String username, int likeid, char type) {
        this.likePK = new LikePK(username, likeid, type);
    }

    public LikePK getLikePK() {
        return likePK;
    }

    public void setLikePK(LikePK likePK) {
        this.likePK = likePK;
    }

    public User getUser() {
        return user;
    }

    public void setUser(User user) {
        this.user = user;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (likePK != null ? likePK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Like)) {
            return false;
        }
        Like other = (Like) object;
        if ((this.likePK == null && other.likePK != null) || (this.likePK != null && !this.likePK.equals(other.likePK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entities.Like[ likePK=" + likePK + " ]";
    }
    
}
